import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;


public class VendingMachineItemTest { 

	VendingMachineItem myVendingMachineItem;
	
	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	/* 
	 * Test case 1 will test the constructor to make sure it isnt null  
	 * 
	 */

	@Test
	public void testVendingMachineItem_Case1() {
		myVendingMachineItem = new VendingMachineItem("snickers", 1.00);	
		assertNotNull(myVendingMachineItem);

	}

	/* 
	 * Test case 2 will test the constructor to make sure it isnt negative  
	 * 
	 */
	
	@Test(expected = VendingMachineException.class)
	public void testVendingMachineItem_Case2() {
		myVendingMachineItem = new VendingMachineItem("snickers", -1.00);	
	}
	
	/* 
	 * Test case 3 will throw an exception if the item name is blank  
	 * 
	 */
	
	@Test(expected = VendingMachineException.class)
	public void testVendingMachineItem_Case3() {
		myVendingMachineItem = new VendingMachineItem("", 1.00);	
	}
	
	/* 
	 * Test case 4 will make sure the item name is returned
	 * 
	 */
	
	@Test
	public void testVendingMachineItem_Case4() {
		myVendingMachineItem = new VendingMachineItem("snickers", 1.00);	
		assertEquals("snickers", myVendingMachineItem.getName());
	}
	
	/* 
	 * Test case 5 will make sure the accurate price is entered  
	 * 
	 */
	
	@Test
	public void testVendingMachineItem_Case5() {
		myVendingMachineItem = new VendingMachineItem("snickers", 1.00);	
		assertEquals(1.00, myVendingMachineItem.getPrice(), 0.00);
	}
	
	/* 
	 * Test case 6 will make sure null isnt accepted   
	 * 
	 */
	
	@Test(expected = VendingMachineException.class)
	public void testVendingMachineItem_Case6() {
		myVendingMachineItem = new VendingMachineItem(null, 1.00);	
		
	}
	
	/* 
	 * Test case 7 will make sure that a snickers is returned
	 * 
	 */
	
	@Test
	public void testGetName_Case7() {
		myVendingMachineItem = new VendingMachineItem("snickers", 1.00);
		assertEquals("snickers", myVendingMachineItem.getName());
	}

	/* 
	 * Test case 8 will make sure right price is returned
	 * 
	 */
	
	@Test
	public void testGetPrice_Case8() {
		myVendingMachineItem = new VendingMachineItem("snickers", 1.00);
		assertEquals(1.00, myVendingMachineItem.getPrice(), 0.00);
	}

}
